﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

using Telerik.Windows.Controls;
using SaleLibrary.Sale;
using BrokerBase.Lib.Core;
using SaleLibrary.Score;

namespace Broker.Mgr.SaleView
{
    /// <summary>
    /// Interaction logic for ClientForm.xaml
    /// </summary>
    public partial class ClientForm
    {
        private IClient client;

        public ClientForm(IClient client):base()
        {
            this.client = client;
            InitializeComponent();
            Loaded += new RoutedEventHandler(ClientForm_Loaded);
        }

        void ClientForm_Loaded(object sender, RoutedEventArgs e)
        {
            DataContext = client;

        }

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (!Verify())
            {
                return;
            }

            try
            {

                IBaseService<Client> svr = new BaseService<Client>(AppGlobal.HbmSessionFactory.GetCurrentSession());

                svr.SaveOrUpdate(client as Client);

                MessageBox.Show("保存成功!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示");
            }

        }

        private void btnExit_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private bool Verify()
        {
            return true;
        }

        private void btnScoreExchangeRecordNew_Click(object sender, RoutedEventArgs e)
        {

        }

        private void btnScoreExchangeRecordDelete_Click(object sender, RoutedEventArgs e)
        {

        }

        private void dgdExchangeRecord_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {

        }

        private void btnScoreExchangeRecordView_Click(object sender, RoutedEventArgs e)
        {

        }

    }
}
